#include "../source/prjlog.h"
#include <unistd.h>

void test_log(const std::string & name)
{
    INFO("%s", "测试日志开始");
    PRJLOG::Logger::ptr ptr = PRJLOG::loggermanagers::GetInstance().getlogger(name);
    ptr->debug("%s", "测试日志");
    ptr->info("%s", "测试日志");
    ptr->warn("%s", "测试日志");
    ptr->error("%s", "测试日志");
    ptr->fatal("%s", "测试日志");
    INFO("%s", "测试日志完毕");
}

int main()
{
    std::unique_ptr<PRJLOG::LoggerBuilder> logger(new PRJLOG::GlobalLoggerBuilder());
    logger->BuildLoggername("SyncLogger");
    logger->BuildLoggerType(PRJLOG::LoggerType::Logger_Sync);
    logger->BuildFormatter("[%c][%f:%l]%m%n");
    logger->BuildLoggerLevel(PRJLOG::LogLevel::value::DEBUG);
    logger->BuildSink<PRJLOG::StdoutSink>();
    logger->BuildSink<PRJLOG::FileSink>("./logfile/sync.log");
    logger->BuildSink<PRJLOG::RollbysizeSink>("./logfile/sync-roll-by-size-",1024*1024*10);
    logger->Builder();
    test_log("SyncLogger");
    return 0;
}